<?php if($this->session->userdata('logged_in')) : ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>.: BooMS v1.1 :.</title>
<link type="text/css" rel="stylesheet" href="<?php echo base_url(); ?>/css/reset.css" />
<link type="text/css" rel="stylesheet" href="<?php echo base_url(); ?>/css/960.css" />
<link type="text/css" rel="stylesheet" href="<?php echo base_url(); ?>/css/main.css" />
<link type="text/css" rel="stylesheet" href="<?php echo base_url(); ?>/css/datepicker.css" />
<script type="text/javascript" src="<?php echo base_url(); ?>/js/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>/js/jquery-ui-1.8.9.custom.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>/js/datepicker.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>/js/jquery.qtip-1.0.0-rc3.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>/js/tinymce/jscripts/tiny_mce/jquery.tinymce.js"></script>
</head>

<body>

<div id="wrap">
	<div id="top">
        <div id="globalNavigation">
        	<div id="user">
            	<ul>
                	<li><a href="#">Change info</a></li>
                    <li><a href="<?php echo site_url().'/gafs/logout'; ?>">Log out</a></li>
                </ul>
            </div>
        	<div id="logo">
            	<h1>BooMS</h1>
                <p><em>Boo's website content management</em></p>
            </div>
        	<div id="menu">
                <ul>
                    <li class="selected"><a href="#">Product</a></li>
                    <li><a href="#">News</a></li>
                    <li><a href="#">Advertiment</a></li>
                    <li><a href="#"></a></li>
                </ul>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    
     <form action="<?php echo base_url();?>index.php/booms/update" name="frm" id="frm" method="post" >
    <div id="middle">
    	<div id="middleWrap" class="container_24">
        	<h1><a href="#">Product Management</a> &raquo; Update Product</h1>
	       
            <div id="productAddNew" class="product booForm">
    			<?php if(isset($productInfo)):?>
                <div class="grid_16">
                    <div class="grid_8 alpha">
                        <div class="formItem text">
                            <div class="grid_2 alpha"><label for="pName">Name:</label></div>
                            <div class="grid_6 omega"><input type="text" class="large required" id="pName" name="pName" value="<?php echo $productInfo->p_name; ?>" /></div>
                            <div class="clear"></div>
                        </div>
                        <div class="formItem text">
                            <div class="grid_2 alpha"><label for="pCode">Code:</label></div>
                            <div class="grid_6 omega"><input type="text" class="medium required" id="pCode" name="pCode" value="<?php echo $productInfo->p_code; ?>" /></div>
                            <div class="clear"></div>
                        </div>
                        <div class="formItem text">
                            <div class="grid_2 alpha"><label for="pDate">Date:</label></div>
                            <div class="grid_6 omega"><input type="text" class="medium" id="pDate" name="pDate" value="<?php echo $productInfo->p_date; ?>" /></div>
                            <div class="clear"></div>
                        </div>
                        <div class="formItem text">
                            <div class="grid_2 alpha"><label for="pCode">Material:</label></div>
                            <div class="grid_6 omega"><input type="text" class="medium required" id="pMaterial" name="pMaterial" value="<?php echo $productInfo->material; ?>" /></div>
                            <div class="clear"></div>
                        </div>
                        <div class="formItem text">
                            <div class="grid_2 alpha"><label for="pColor">Color:</label></div>
                            <div class="grid_6 omega"><input type="text" class="medium required" id="pColor" name="pColor" value="<?php echo $productInfo->color; ?>" /></div>
                            <div class="clear"></div>
                        </div>
                        <div class="formItem text">
                            <div class="grid_2 alpha"><label for="pColorImg">Color Img:</label></div>
                            <div class="grid_6 omega"><input type="text" class="medium" id="pColorImg" name="pColorImg" value="<?php echo $productInfo->color_img; ?>" /></div>
                            <div class="clear"></div>
                        </div>
                        <div class="formItem text">
                            <div class="grid_2 alpha"><label for="pPrice">Price:</label></div>
                            <div class="grid_6 omega"><input type="text" class="medium required number" id="pPrice" name="pPrice" value="<?php echo $productInfo->price; ?>" /></div>
                            <div class="clear"></div>
                        </div>
                        
                           
                          <input type="hidden" class="medium" id="pId" name="pId" value="<?php echo $productInfo->p_id; ?>" />
                        
                        
                    </div>
                    <?php 
                            $check =(isset($productInfo->size)) ?  $productInfo->size : "";
                            $arrCheck = explode(',',$check);
                    ?>
                    <div class="grid_8 omega">
                        <div class="formItem checkbox">
                            <div class="grid_2 alpha"><label for="pSize">Size:</label></div>
                            <div class="grid_6 omega">
                            <?php foreach($arrSizeChar as $sizeChar):  ?>                            	
                                <?php echo $sizeChar;?><input type="checkbox" name="check[]"  <?php if(in_array($sizeChar,$arrCheck)){ echo 'checked="checked"'; } ?> 
                                value="<?php echo $sizeChar;?>" />
                            <?php endforeach; echo br(2);?>
                            
                            <?php foreach($arrSizeNumber as $sizeNumber): ?>
                                <?php echo $sizeNumber;?><input type="checkbox" name="check[]" <?php if(in_array($sizeNumber,$arrCheck)){echo 'checked="checked"';} ?> value="<?php echo $sizeNumber;?>" />
                            <?php endforeach;?>
                            </div>
                            <div class="clear"></div>
                        </div>
                        
                        <div class="formItem optionbox">
                            <div class="grid_2 alpha"><label for="pStatus">Show:</label></div>
                            <div class="grid_6 omega">
                                Yes<input type="radio" id="pStatus" name="pStatus" value="1" <?php if($productInfo->status==1){ echo 'checked="checked"';} ?> />&nbsp;
                                No<input type="radio" id="pStatus" name="pStatus" value="0" <?php if($productInfo->status==0){ echo 'checked="checked"';} ?> />
                            </div>
                            <div class="clear"></div>
                        </div>
                        <div class="formItem optionbox">
                            <div class="grid_2 alpha"><label for="pIsHome">Is home:</label></div>
                            <div class="grid_6 omega">Yes<input type="radio" id="pIsHome" name="pIsHome" value="1" 
							<?php if($productInfo->is_home==1){ echo 'checked="checked"';} ?> />&nbsp;
                                No<input type="radio" id="pIsHome" name="pIsHome" value="0" <?php if($productInfo->is_home==0){ echo 'checked="checked"';}  ?> /></div>
                            <div class="clear"></div>
                        </div>
                        <div class="formItem optionbox">
                            <div class="grid_2 alpha"><label for="pIsHot">Is hot:</label></div>
                            <div class="grid_6 omega">
                                Yes<input type="radio" id="pIsHot" name="pIsHot" value="1" 
							<?php if($productInfo->is_hot==1){ echo 'checked="checked"';}  ?> />&nbsp;
                                No<input type="radio" id="pIsHot" name="pIsHot" value="0" <?php if($productInfo->is_hot==0){ echo 'checked="checked"';}  ?> /></div>
                            <div class="clear"></div>
                        </div>
                        <div class="formItem optionbox">
                            <div class="grid_2 alpha"><label for="pIsHome">Is sale:</label></div>
                            <div class="grid_6 omega">Yes<input type="radio" id="pIsSale" name="pIsSale" value="1" 
							<?php if($productInfo->is_sale==1){ echo "checked='checked'";} ; ?> />&nbsp;
                                No<input type="radio" id="pIsSale" name="pIsSale" value="0" <?php if($productInfo->is_sale==0){ echo 'checked="checked"';}  ?> />
                            </div>
                            <div class="clear"></div>
                            <div class="grid_2 alpha"><label>Type:</label></div>
                            <div class="grid_2"> <input class="small" type="text" id="pSaleType" name="pSaleType" value="<?php echo $productInfo->sale_type; ?>"  /></div>
                            <div class="grid_2 alpha"><label>Value:</label></div>
                            <div class="grid_2 omega"><input class="small" type="text" id="pSaleValue" name="pSaleValue" value="<?php echo $productInfo->sale_value; ?>" /></div>
                            <div class="clear"></div>
                        </div>
                        
                    </div>
                    <div class="clear"></div>
                    <div class="formItem text">
                        <div class="grid_2 alpha"><label for="pPicture">Pictures:</label></div>
                        <div class="grid_13 omega"><input type="text" class="superLarge required" id="pPicture" name="pPicture" value="<?php echo $productInfo->p_pictures; ?>" /></div>
                        <div class="clear"></div>
                    </div>
                    <div id="descriptionWrap" class="formItem">
                    <h3>Description:</h3>
                    	<textarea id="pDes" name="pDes"><?php echo $productInfo->p_des; ?></textarea>
                    </div>
                </div>
                <div class="grid_8">
                	<div class="formItem listbox">
                    <label class="alignLeft">Category</label>
                        <select name="pCatCode" id="pCatCode" size="10">
                            <?php if(isset($fcnu)){ ?>
                            <optgroup label="Nữ">
                            	<?php foreach($fcnu as $nu):?>
                                <option value="<?php echo $nu->pcat_code;?>" <?php if($productInfo->pcat_code==$nu->pcat_code){ echo "selected='selected'";} ?> ><?php echo $nu->menu_name." - ".$nu->pcat_name;?></option> 
                                <?php endforeach;?>
                            </optgroup>
                            <?php } ?>
                             <?php if(isset($fcnam)){ ?>
                            <optgroup label="Nam">
                                <?php foreach($fcnam as $nam):?>
                                <option value="<?php echo $nam->pcat_code;?>" <?php if($productInfo->pcat_code==$nam->pcat_code){ echo "selected='selected'";} ?> ><?php echo $nam->menu_name." - ".$nam->pcat_name;?></option> 
                                <?php endforeach;?>
                            </optgroup>
                            <?php } ?>
                        </select>
                    </div>
                    <div class="formItem listbox">
                        <label class="alignLeft">Brand</label>
                        <select name="pBrand" id="pBrand" size="10" >
                        <?php if(isset($ftbrand)){ ?>              
                            	<?php foreach($ftbrand as $fb):?>
                                <option value="<?php echo $fb->brand_alias;?>" <?php if($productInfo->brandcode==$fb->brand_alias){ echo "selected='selected'";} ?>><?php echo $fb->brand_name;?></option> 
                                <?php endforeach;?>
                         <?php } ?>
                        </select>
                    </div>
                </div>
                <?php endif;?>
                <div class="clear"></div>
           
            </div>
           
            <div class="actionBar product">
            	<div class="actionMenu grid_19">
            	<ul>
                	<li><a href="#" id="btnDisplay"  >Display</a></li>
                    <li><a style="cursor:pointer;" onclick=" $('#frm').submit();">Save</a></li>
                </ul>
                </div>
            </div>
    </div>
    <div id="bottom">
    	<div class="threeCol"></div>
        <div class="threeCol"></div>
        <div class="threeCol"></div>
        <div class="clear"></div>
    </div>
</div>
     </form>
<!-- Tiny MCE -->


<!-- Date picker -->
<script type="text/javascript">
	$('#pDate').DatePicker({
		format:'Y-m-d',
		date: $('#pDate').val(),
		current: $('#pDate').val(),
		starts: 1,
		position: 'r',
		onBeforeShow: function(){
				$('#pDate').DatePickerSetDate($('#pDate').val(), true);
		},
		onChange: function(formated, dates){
				$('#pDate').val(formated);
				//if ($('#closeOnSelect input').attr('checked')) {
						$('#pDate').DatePickerHide();
				//}
		}
	});
</script>

<script type="text/javascript">
	$(document).ready(function(){
		$('#frm').validate({
			rules: {
				rang: {
				  required: true,
				  range: [0, 100]
				}
			  }	
			});
	});
</script>

<script type="text/javascript">
/*
* Example submit	
*/
    $("a#btnDisplay").click(function(){
       if(confirm('You want submit before redirect ?')){
		   $("#frm").submit(); 
		   $("#frm").attr('action','<?php echo base_url();?>index.php/booms/index');
	   }else{
			window.location ="<?php echo base_url();?>index.php/booms/index";   
	   }
	   		
    });
</script>
</body>
</html>
<?php else : redirect('gafs/index/'); ?>

<?php endif; ?>